﻿Public Class CWordDetail
    Dim _ID As String
    Dim _CEnglishMemo As CEnglishMemo
    Public Property ID() As String
        Set(ByVal value As String)
            _ID = value
        End Set
        Get
            Return _ID
        End Get
    End Property

    Public Sub LoadData(ByVal strId As String)
        Dim rs As ADODB.Recordset = ct.GetTable("select * from XSCENLISHWORD where ID='" + strId + "'")
        If rs Is Nothing Then Exit Sub
        If rs.EOF = False Then
            Me.lstEnglistWord.Text = CMainModule.CmnToStr(rs.Fields("WORD").Value)
            Me.lstChinaWord.Text = CMainModule.CmnToStr(rs.Fields("CHINESEWORD").Value)
            Me.lstJuzi.Text = CMainModule.CmnToStr(rs.Fields("MEMO").Value)
            Me.txt美国音标.Text = CMainModule.CmnToStr(rs.Fields("SyombalAmerican").Value)
            Me.txt英国音标.Text = CMainModule.CmnToStr(rs.Fields("SyombalEnglish").Value)
            rs.Close()
            System.Runtime.InteropServices.Marshal.ReleaseComObject(rs) '20100531
            rs = Nothing
        End If
        Me.txt美国音标.Font = New Drawing.Font("Lucida Sans Unicode", Me.lstChinaWord.Font.Size)
        Me.txt英国音标.Font = New Drawing.Font("Lucida Sans Unicode", Me.lstChinaWord.Font.Size)
        Me.btnUpdate.Focus()
    End Sub

#Region "增加算法 查询的单词 要最前面显示 A-2009-09-26"
    Private Sub CWordDetail_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Try
            Dim cmd As New ADODB.Command
            cmd.CommandText = "Update XSCENLISHWORD set Count=Count+1,OPTIME=? where id=?"
            Dim pa As ADODB.Parameter = cmd.CreateParameter(, ADODB.DataTypeEnum.adDBTimeStamp, ADODB.ParameterDirectionEnum.adParamInput, 100, DateTime.Now.ToString())
            cmd.Parameters.Append(pa)
            pa = cmd.CreateParameter(, ADODB.DataTypeEnum.adVarWChar, ADODB.ParameterDirectionEnum.adParamInput, ID.Length, ID)
            cmd.Parameters.Append(pa)
            ct.ExcCommand(cmd)

            _CEnglishMemo.添加记录(CommonModule.当前英语备注ID, lstEnglistWord.Text.Trim.ToUpper)
        Catch ex As Exception
        End Try
    End Sub
#End Region

    Private Sub CWordDetail_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadData(ID)
        _CEnglishMemo = New CEnglishMemo(ct)
    End Sub

#Region "更新记录 A-2009-08-24"
    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Try
            Dim strSql As String = "select ID,WORD from XSCENLISHWORD Where ID='" + Me.ID + "'"
            Dim strSql1 As String = "select count(*) as PageCount from XSCENLISHWORD  Where ID='" + Me.ID + "'"
            Dim frm As New ListEnglishWord
            frm.iType = Me.iType
            frm.strName = Me.strName
            frm.iListToUpdate = 1
            frm.LoadListToUpdate(strSql, strSql1)
            frm.ShowDialog()
            LoadData(ID)
            frm.Dispose()
            frm = Nothing
        Catch ex As Exception

        End Try
       
    End Sub
#End Region

End Class
